<?php

class Model_Auth
{
    /**
     * @param string $identity
     * @param string $credential
     * @return bool
     */
    public static function authenticate($identity, $credential)
    {
        $adapter = new Zend_Auth_Adapter_DbTable(
            null, 'member', 'email', 'password', 'SHA1(concat(?, salt)) AND status = ' . Model_Member::STATUS_ACTIVE
        ); 
        $adapter->setIdentity($identity);
        $adapter->setCredential($credential);

        $auth   = Zend_Auth::getInstance();
        $result = $auth->authenticate($adapter);
        if ($result->isValid()) {
            $auth->getStorage()->write($adapter->getResultRowObject());
            return true;
        }
        return false;
    }
}